package com.ubxtech.jdk21.controller;

import com.ubxtech.core.context.Result;
import com.ubxtech.jdk21.req.RecordTest;
import com.ubxtech.jdk21.req.TestReq;
import com.ubxtech.jdk21.service.TestService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author Victor.Xiao
 * @since 2023-02-17 17:19
 **/
@Slf4j
@RestController
@RequestMapping("/test")
@Tag(name = "testTestController")
public class TestController {

    @Resource
    private TestService testService;

    @Operation(summary = "获取详情")
    @PostMapping("/test")
    public Result<String> test(@Validated TestReq req) {
        try {
            return Result.ok(testService.test(req));
        } catch (Exception e) {
            log.error("升级服务失败updateService",e);
        }
        return Result.ok("");
    }

    @Operation(summary ="recordTest  ApiOperation")
    @PostMapping("/recordTest")
    public Result<Void> recordTest(@Validated RecordTest req) {

        return Result.ok();
    }

    @Operation(summary ="springboot3Test  ApiOperation")
    @GetMapping("/springboot3Test")
    public Result<Void> springboot3Test(@Validated TestReq req) {
        System.out.println(req.getServiceId()+"============");
//        System.out.println(1/0);
        return Result.ok();
    }
}
